package com.example.design.patterns.冰河.行为模式.迭代器模式;

import com.example.design.patterns.冰河.行为模式.迭代器模式.concreteAggregate.ListImpl;
import com.example.design.patterns.冰河.行为模式.迭代器模式.iterator.Iterator;

public class Test {
    public static void main(String[] args) {
        ListImpl list = new ListImpl();
        list.add("a");
        list.add("b");
        list.add("c");
        //第一种迭代方式
        Iterator iterator = list.Iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        System.out.println("--------------------");
        //第二种迭代方式
        for (int i = 0; i < list.getSize(); i++) {
            System.out.println(list.get(i));

        }
    }
}
